package com.mls.fivedistrict.controller.portal;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mls.fivedistrict.common.PageFilter;
import com.mls.fivedistrict.common.RequestHolder;
import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.pojo.Message;
import com.mls.fivedistrict.server.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * <p>
 * 消息表 前端控制器
 * </p>
 *
 * @author Five Team
 * @since 2018-06-26
 */
@RestController("protalMessageController")
@RequestMapping("/api/app")
public class MessageController {
    @Autowired
    MessageService messageService;
    /**
     * 消息列表
     * @return
     */
    @GetMapping("/v1/messages")
    public ServiceResponse getMessageList(){
        PageFilter pageFilter = RequestHolder.getPageFilter();
        PageHelper.startPage(pageFilter.getPageNum(),pageFilter.getPageSize());
        List selectList = messageService.selectList(pageFilter.getWrapper());
        PageInfo<Message> messagePageInfo = new PageInfo<Message>(selectList, 5);
        return  ServiceResponse.createSuccessResponse(messagePageInfo);
    }
}

